package Thread;

public class Demo10 {
    private static Object locker1=new Object();
    private static Object locker2=new Object();

    public static void main(String[] args) {
        Thread thread1=new Thread(()->{
            System.out.println("A");
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            synchronized (locker1){
                locker1.notify();
            }
        });
        Thread thread2=new Thread(()->{
            synchronized (locker1){
                try {
                    locker1.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("B");
            synchronized (locker2){
                locker2.notify();
            }
        });
        Thread thread3=new Thread(()->{
            synchronized (locker2){
                try {
                    locker2.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("C");
        });
        thread1.start();
        thread2.start();
        thread3.start();
    }
}
